﻿using System;

namespace LightPersist.Transactions
{
	internal class NullTransaction : Transaction
	{
		public static readonly NullTransaction Instance = new NullTransaction();
		private readonly bool constructed;

		private NullTransaction()
		{
			constructed = true;
		}

		public override TransactionState State
		{
			get
			{
				return TransactionState.Unknown;
			}
			internal set
			{
#if DEBUG
				if (constructed)
				{
					throw new ApplicationException("Trying to change state of current transaction, but it is does not opened");
				}
#endif
			}
		}

		public override bool SkipDuringProcess
		{
			get
			{
				return true;
			}
			internal set
			{
#if DEBUG
				throw new ApplicationException();
#endif
			}
		}

		public override string ToString()
		{
			return "TR_NULL";
		}
	}
}